package com.fimmlps.reronge.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fimmlps.reronge.entity.EntryUserApply;
import com.fimmlps.reronge.mapper.EntryUserApplyMapper;
import com.fimmlps.reronge.service.IEntryUserApplyService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EntryUserApplyServiceImpl extends ServiceImpl<EntryUserApplyMapper, EntryUserApply> implements IEntryUserApplyService {
    @Override
    public EntryUserApply getApplyBySSIDs(int senderId, int sendeeId) {
        List<EntryUserApply> apply = baseMapper.selectList(new QueryWrapper<EntryUserApply>().eq("entry_apply_type",0).eq("entry_user_sender_id",senderId).eq("entry_user_sendee_id",sendeeId).eq("entry_apply_result",0));
        if(apply.size()>0)
            return apply.get(0);
        return null;
    }

    @Override
    public EntryUserApply getApplyBySendID(int senderId) {
        List<EntryUserApply> apply = baseMapper.selectList(new QueryWrapper<EntryUserApply>().eq("entry_apply_type",1).eq("entry_user_sender_id",senderId).eq("entry_apply_result",0));
        if(apply.size()>0)
            return apply.get(0);
        return null;
    }
}
